#include "Sprite.h"
#include "TextureManager.h"
Sprite::Sprite(void)
:pTexture(NULL)
{
	printf("==============Sprite\n");
}
Sprite::~Sprite(void)
{
	printf("==============destroy Sprite\n");
}
void Sprite::initWithFile(const char *filename,Size& size)
{
	pTexture = TextureManagerSingleton::getSingleton()->createOrGetTexture(std::string(filename));
	mContentSize = size;
}
void Sprite::update()
{
	Node2D::update();
	std::vector<Node2D*>::iterator it;
	for (it=mChildren.begin(); it<mChildren.end(); it++)
	{
		Node2D* child = (*it);
		child->update();
	}
}
void Sprite::draw(SpriteBatch* spriteBatch)
{
	update();
	if (spriteBatch != NULL)
	{
		if (pTexture != NULL)
		{
			mQuad.tex = pTexture->getTexID();
		}
		spriteBatch->draw(mQuad);
	}
	std::vector<Node2D*>::iterator it;
	for (it=mChildren.begin(); it<mChildren.end(); it++)
	{
		Node2D* child = (*it);
		child->draw(spriteBatch);
	}
}
